package com.learn.java3y.java.object;

import java.util.Date;

/**
 * 深拷贝：不仅拷贝了Person对象，也拷贝了date成员变量
 */
public class Person1 implements Cloneable {

    private Date date;

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person1 person = (Person1) super.clone();
        person.setDate((Date) date.clone());
        return person;
    }

    @Override
    public String toString() {
        return "Person1{" +
                "date=" + date +
                '}';
    }
}
